As an example of this, we construct a typed list from the entities Customer and Order and include the following fields
in the resultset: Order.OrderID, Order.OrderDate, Order.ShippedDate, Customer.CustomerID, Customer.CompanyName.
(Do this by checking these fields in the field list in the typed list editor). You can now filter on any field in Order or Customer
or both. Also, you can sort on any field in Order or Customer or both. Let's filter this typed list on all orders from customers
from 'Brazil', and sort the list on the field Order.Freight, ascending. The typed list is called OrderCustomer.
// [C#] OrderCustomerTypedList orderCustomer = new OrderCustomerTypedList(); IPredicateExpression filter = new PredicateExpression(CustomerFields.Country == "Brazil"); ISortExpression sorter = new SortExpression(OrderFields.Freight | SortOperator.Ascending); // Set allowDuplicates to true, because we sort on a field that is not in our resultset and we use SqlServer. orderCustomer.Fill(0, sorter, true, filter);
' [VB.NET] Dim orderCustomer As New OrderCustomerTypedList() Dim filter As IPredicateExpression = New PredicateExpression( _ New FieldCompareValuePredicate(CustomerFields.Country, ComparisonOperator.Equal, "Brazil")) Dim sorter As ISortExpression = New SortExpression( _ New SortClause(OrderFields.Freight, SortOperator.Ascending)) ' Set allowDuplicates to true, because we sort on a field that is not in our resultset and we use SqlServer. orderCustomer.Fill(0, sorter, True, filter)
Note: |
TypedLists still offer the functionality of Weak Relations through the property ObeyWeakRelations. (See for a description of weak relations this section in Filtering and Sorting). It's however recommended to use the JoinHint specifications for the relations in the TypedList editor in the LLBLGen Pro Designer. |